package pizzadroid.googlecode.com;

import resturant.pizzadroid.googlecode.com.Resturant;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

public class Favorites extends ListActivity {
	private FavoritesAdapter favoritesAdapter;
	private Database db;
	private int progress = 10000; //Will make the progressbar fade out
	//private ProgressBar bar;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
				
		favoritesAdapter = new FavoritesAdapter(this, R.layout.favorites_listitem);
		setListAdapter(favoritesAdapter);
		
		db = new Database(this);
		db.addFavorite(1, "Hepatiten 1");
		db.addFavorite(2, "Hepatiten 2");
		db.addFavorite(3, "Hepatiten 3");
		db.addFavorite(4, "Hepatiten 4");
		
		db.addFavoritesToAdapter(favoritesAdapter);
	}

	
	protected void onDestroy() {
		super.onDestroy();
		db.close();
	}
	
	protected void onListItemClick(ListView l, View v, int position, long id) {
		Toast.makeText(getApplicationContext(), ((Resturant)getListView().getItemAtPosition(position)).id, Toast.LENGTH_SHORT).show();
		getParent().setProgressBarVisibility(true);
		progress = progress + 1000;
		if (progress > 10000) {
			progress = 0;
		}
		getParent().setProgress(progress);
	}
}